package com.chen.seckill;

import com.chen.seckill.dao.UserMapper;
import com.chen.seckill.pojo.User;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication(scanBasePackages = {"com.chen.seckill"})
@MapperScan("com.chen.seckill.dao")
@RestController
public class SeckillApplication {

    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/")
    public String home() {
        User user = userMapper.selectByPrimaryKey(1);
        if (user == null) {
            return "用户不存在";
        } else {
            return user.getName();
        }
    }

    public static void main(String[] args) {
        SpringApplication.run(SeckillApplication.class, args);
    }

}
